<?php
include 'secure/core.php';
include 'user_header.php';
include 'left.php'; 
$first_day = date("Y:m:01 00:00:00");
$sql= "SELECT `e`.`date` , sum(`e`.`amount`) as amount , `u`.`username`
FROM `earnings` AS `e`
INNER JOIN `users` AS `u` ON `e`.`user_id` = `u`.`id` WHERE date > '$first_day'
group by `e`.`user_id` ORDER BY amount DESC
LIMIT 15  ";
$result = $ado->exec($sql);
$fetched_rows = mysql_num_rows($result);
?>
		<div id="right">
		<div class="section">
				<div class="box">
					<div class="title">
						Paid4Upload Leaderboards
						<span class="hide"></span>
					</div>
					<div class="content">
						<table cellspacing="0" cellpadding="0" border="0"> 
							<thead> 
								<tr>
									<th>Username</th>
									<th>Earnings</th>
								</tr>
							</thead>
							<tbody>
                                                       <?php if($fetched_rows>0){
  	                                               while($fetched_rows1 = mysql_fetch_assoc($result)){
                                                       $randrow = round($fetched_rows1['amount'], 2);
                                                       ?>
							<tr>
							  <td><?php echo $fetched_rows1['username'];?></td>
							  <td><?php echo '$'.round($fetched_rows1['amount'], 2);?></td>
							 </tr>
							 <?php }} else { ?>
							 <tr>
							  <td colspan="2">Currently no earnings</td>
							 </tr>
							 <?php } ?>
							 </tbody>
						</table>

					</div>
				</div>
			</div>
		</div>

<?php include 'footer.php'; ?>